<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script>
                function title() {
                    document.getElementById('atendimento').className='selected';
                }
                window.onload=title;
            </script>
            <f:metadata>
                <f:viewParam name="date" value="#{managerAtendimento.dateString}"/>
            </f:metadata>
            
            <h:form id="diaryForm" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Atendimento
                </h1>
                <p:messages autoUpdate="true" id="messages" closable="true"/>
                <div class="row">
                    <div class="twelve columns">
                        <div class="container_24 clearfix ">
                            <p:button icon="ui-icon-plusthick" value="Cadastrar Paciente" 
                                      style="float: right; margin-top: -10px;"
                                      outcome="createcustomer.xhtml" styleClass="ui-priority-primary">
                                <f:param name="atendimentopaciente" value="true" />
                                <f:param name="date" value="#{managerAtendimento.dateString}" />
                            </p:button>
                            <div class="clear"/>
                            <fieldset>
                                <legend> <h4 style="margin:0 0 10px 0">Pesquisar Paciente</h4></legend>

                                <p:panel id="customerPrimarySearch" 
                                         style="background: none; border: none;" 
                                         styleClass="container_24 clearfix ">

                                    <div class="grid_24">
                                        <p:outputLabel for="nameSearch" value="Nome:" styleClass="grid_3"/>
                                        <p:inputText id="nameSearch" styleClass="grid_20" value="#{managerAtendimento.customerpesquisar.name}"/>
                                        <p:outputLabel for="cpfSearch" value="CPF:" styleClass="grid_3"/>
                                        <p:inputMask id="cpfSearch" mask="999.999.999-99" styleClass="grid_8" value="#{managerAtendimento.customerpesquisar.cpf}"/>
                                        <div class="clear"></div>

                                        <div class="buttonAction">
                                            <p:defaultCommand target="search-button" />
                                            <p:commandButton id="search-button" value="Pesquisar" icon="ui-icon-search"
                                                             update="customerPrimarySearch" process="customerPrimarySearch" 
                                                             actionListener="#{managerAtendimento.searchCustomer()}"
                                                             styleClass="ui-priority-primary" />
                                            <p:commandButton  value="Cancelar" icon="ui-icon-search"
                                                              update="customerPrimarySearch" process="customerPrimarySearch" />
                                        </div>
                                    </div>

                                    <p:dataTable id="tablePac" var="pac" value="#{managerAtendimento.customers}" 
                                                 styleClass="grid_24"
                                                 rowIndexVar="rowid"
                                                 rowKey="#{pac.id}"
                                                 rows="5" paginator="true"  
                                                 paginatorPosition="bottom"

                                                 emptyMessage="Nenhum registro">  
                                        <f:facet name="header">
                                            Pacientes
                                        </f:facet>
                                        <p:ajax event="rowSelect"  process="@this" update="@this"/>
                                        <p:ajax event="rowUnselect"  process="@this" update="@this"/>
                                        <p:column headerText="Ação" width="25">  
                                            <p:button icon="ui-icon-search" style="width: 25px; position: relative;"
                                                      outcome="atendimentoperfil.xhtml" >
                                                <f:param name="step" value="2" />
                                                <f:param name="customer" value="#{pac.id}" />
                                                <f:param name="date" value="#{managerAtendimento.dateString}" />
                                            </p:button>

                                        </p:column>  
                                        <p:column headerText="Nome" width="400">  
                                            <h:outputText value="#{pac.name}"/>
                                        </p:column>  
                                        <p:column headerText="CPF" width="150">  
                                            <h:outputText value="#{pac.cpf}"/>
                                        </p:column>
                                        <p:column headerText="Contato" width="150">  
                                            <h:outputText value="#{pac.cellular}"/>
                                        </p:column>


                                    </p:dataTable>
                                </p:panel>
                            </fieldset>
                        </div>
                    </div>
                </div>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
